// miniprogram/pages/welcome/welcome.js
const app = getApp()
Page({
	/**
	 * 页面的初始数据
	 */
	data: {
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {
		wx.cloud.callFunction({
			name: 'login',
			data: {},
			success: res => {
				console.log('[云函数] [login] user openid: ', res.result.openid)
				app.globalData.openid = res.result.openid
			},
			fail: err => {
				console.error('[云函数] [login] 调用失败', err)
			}
		})
	},
	onShow: function () {
		var value = wx.getStorageSync('userinfo')
		if(value){
			wx.switchTab({
				url: "../daybook/daybook"
			})
		}else{
			wx.navigateTo({
				url: "../login/login"
			})
		}
	},
})